package com.lorenzogao.pley.ui.presenter

import com.lorenzogao.pley.bean.Category
import com.lorenzogao.pley.common.rx.RxHttpReponseCompat
import com.lorenzogao.pley.common.rx.subscriber.ProgressSubcriber
import com.lorenzogao.pley.ui.presenter.contract.CategoryContract
import javax.inject.Inject

/**
 * 作者：Lorenzo Gao
 * Date: 2018/1/6
 * Time: 12:29
 * 邮箱：2508719070@qq.com
 * Description:
 */
class CategoryPresenter @Inject constructor(mModel: CategoryContract.ICategoryModel, mView: CategoryContract.CategoryView) : BasePresenter<CategoryContract.ICategoryModel, CategoryContract.CategoryView>(mModel, mView) {


    fun getAllCategory() {
        mModel!!.getCategories().compose(RxHttpReponseCompat.compatResult()).subscribe(object : ProgressSubcriber<List<Category>>(mContext!!, mView!!) {
            override fun onNext(t: List<Category>?) {
                if (t != null) {
                    mView!!.showData(t)
                }
            }

        })
    }
}